package com.ruoyi.wechat.service.impl;

import java.util.List;

import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.wechat.domain.Image;
import com.ruoyi.wechat.service.IImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wechat.mapper.CommunicationMapper;
import com.ruoyi.wechat.domain.Communication;
import com.ruoyi.wechat.service.ICommunicationService;

/**
 * 营地交流Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-25
 */
@Service
public class CommunicationServiceImpl implements ICommunicationService 
{
    @Autowired
    private CommunicationMapper communicationMapper;

    @Autowired
    private IImageService imageService;

    /**
     * 查询营地交流
     * 
     * @param communicationId 营地交流主键
     * @return 营地交流
     */
    @Override
    public Communication selectCommunicationByCommunicationId(String communicationId)
    {
        return communicationMapper.selectCommunicationByCommunicationId(communicationId);
    }

    /**
     * 查询营地交流列表
     * 
     * @param communication 营地交流
     * @return 营地交流
     */
    @Override
    public List<Communication> selectCommunicationList(Communication communication)
    {
        return communicationMapper.selectCommunicationList(communication);
    }

    /**
     * 新增营地交流
     * 
     * @param communication 营地交流
     * @return 结果
     */
    @Override
    public int insertCommunication(Communication communication)
    {
        communication.setCommunicationId(IdUtils.randomUUID());
        for (int i = 0; i < communication.getImageList().size(); i++) {
            communication.getImageList().get(i).setCommunicationId(communication.getCommunicationId());
            communication.getImageList().get(i).setImgId(IdUtils.randomUUID());
            imageService.insertImage(communication.getImageList().get(i));
        }
        return communicationMapper.insertCommunication(communication);
    }

    /**
     * 修改营地交流
     * 
     * @param communication 营地交流
     * @return 结果
     */
    @Override
    public int updateCommunication(Communication communication)
    {
        return communicationMapper.updateCommunication(communication);
    }

    /**
     * 批量删除营地交流
     * 
     * @param communicationIds 需要删除的营地交流主键
     * @return 结果
     */
    @Override
    public int deleteCommunicationByCommunicationIds(String[] communicationIds)
    {
        return communicationMapper.deleteCommunicationByCommunicationIds(communicationIds);
    }

    /**
     * 删除营地交流信息
     * 
     * @param communicationId 营地交流主键
     * @return 结果
     */
    @Override
    public int deleteCommunicationByCommunicationId(String communicationId)
    {
        return communicationMapper.deleteCommunicationByCommunicationId(communicationId);
    }
}
